struct ListNode* addTwoNumbers(struct ListNode* l1, struct ListNode* l2) {
    struct ListNode* head = NULL;
    struct ListNode* tail = NULL;
    int s = 0;
    while (l1 || l2)
    {
        int n1 = l1 ? l1->val : 0;
        int n2 = l2 ? l2->val : 0;
        int n = n1 + n2 + s;
        if (head == NULL)
        {
            head = tail = (struct ListNode*)malloc(sizeof(struct ListNode));
            head->val = n % 10;
            head->next = NULL;
            s = n / 10;
        else
        {
            tail->next = (struct ListNode*)malloc(sizeof(struct ListNode));
            tail = tail->next;
            tail->val = n % 10;
            tail->next = NULL;
            s = n / 10;

        }
        if (l1)
            l1 = l1->next;
        if (l2)
            l2 = l2->next;
        }
        if (s == 1)
        {
            tail->next = (struct ListNode*)malloc(sizeof(struct ListNode));
            tail->next->next = NULL;
            tail->next->val = 1;
        }
        return head;
    }